<template>
	<view>
		<view class="nav_container">
			<view class="nav_box"
				:style="{'height':navHeight+'px','padding-top':statusBarHeight+'px','backgroundColor':bgColor}" :class="{'bg-class':bgClass  }">
				<view class="icon" v-if="$slots.icon">
					<slot name="icon"></slot>
				</view>
				<view v-else class="icon" color='#000'>
					<block v-if='black'>
						<u-icon name="arrow-left" size='20' :color='iconColor' @click="clickBack"></u-icon>
					</block>
				</view>
				<view class="title" :style="{'color':titleColor}">
					{{title}}
				</view>
				<view></view>
			</view>
		</view>
		<view class="nav" :style="{'height':navHeight+'px'}" v-if="hasHeight">

		</view>
	</view>
</template>


<script>
	const app = getApp();
	export default {
		data() {
			return {
				navHeight: app.globalData.navHeight,
				statusBarHeight: app.globalData.statusBarHeight, //状态栏高度
			}
		},
		props: {
			fileList:{
				type:Array,
				default:[]
			},
			//语音
			audioSrc:{
				type:String,
				default:""
			},
			//用来返回的时候数据进行改变
			page:{
				type:String,
				default:""
			},
			/**
			 * 组件的属性列表
			 */
			//高度
			hasHeight:{
				type:Boolean,
				default:true
			},
			//控制渐变
			bgClass:{
				type:Boolean,
				default:false
			},
			title: {
				type: String,
				default: ""
			},
			black: {
				type: Boolean,
				default: false
			},
			iconColor: {
				type: String,
				default: "#000"
			},
			titleColor: {
				type: String,
				default: "#000"
			},
			bgColor: {
				type: String,
				default: "#fff"
			},
		},
		methods: {
			clickBack() {
				let pages= getCurrentPages();
				let prevPage = pages[pages.length - 2];
				let curPage = pages[pages.length - 1];
				
				if(this.page){
					prevPage.$vm._data.audioSrc = this.audioSrc;
					prevPage.$vm._data.imgList = this.fileList;
				}
				
				
				// console.log(pages);
				// console.log(pages[0].$page.fullPath)
				if(pages[0].$page.fullPath == '/pages/doLogin/doLogin' ){
					console.log(13233)
					uni.reLaunch({
						url:'../../pages/index/index?current=0'
					})
				}
				else if(prevPage.route == 'pages/orderDetailPage/orderDetailPage' && curPage.$vm._data.success == 1){
					uni.reLaunch({
						url:'../../pages/index/index?current=3'
					})
				}else{
					uni.navigateBack({})
				}
			}

		},

		mounted() {
			// console.log(123)
			// console.log(app.globalData);
		}
	}
</script>

<style scoped lang="scss">
	.nav_container {
		width: 100%;
		z-index: 999;
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
	}

	.nav_box {
		display: flex;
		align-items: center;
		justify-content: center;
		box-sizing: border-box;
		position: relative;
		/* border-bottom: 2rpx solid #F8F8F8; */
		z-index: 999;

		view {
			flex: 1;
			text-align: center;

			&:first-of-type {
				text-align: left;
				position: relative;
				left: 30rpx;
			}
		}

	}

	.bgWhite {
		background-color: #fff;
	}

	.title {
		color: #333333;
		font-family: PingFang-SC-Bold;
		font-size: 34rpx;
		// font-weight: 600;
	}
	
	.bg-class{
		background-image: linear-gradient(to right , #FFC2A1 , #FFB1BC);
	}
</style>
